import sqlite3

def convert(value):
    return value.strip('"[]')

dbname = "tmp/food.db"
conn = sqlite3.connect(dbname)
curs = conn.cursor()
curs.execute('''
CREATE TABLE food (
ip TEXT,
logtime TEXT,
logzone TEXT,
method TEXT,
url TEXT,
proto TEXT,
status INT,
val1 TEXT,
val2 TEXT,
val3 TEXT,
val4 TEXT
)
''')

query = 'INSERT INTO food VALUES (?,?,?,?,?,?,?,?,?,?,?)'
field_count = 11

for line in open('tmp/access.log'):
    fields = line.split()
    vals = [convert(f) for f in fields[:field_count]]
    curs.execute(query, vals)
conn.commit()

print(list(curs.execute('select * from food order by ip')))

conn.close()
